package com.looli.common.exception;

import com.looli.common.result.ResponseEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class BusinessException extends RuntimeException {

    //状态码
    private Integer code;

    //错误消息
    private String message;

    public BusinessException(ResponseEnum responseEnum) {
        this.code = responseEnum.getCode();
        this.message = responseEnum.getMessage();
    }
    public BusinessException(String message) {
        this.code = -500;
        this.message = message;
    }
    public BusinessException(ResponseEnum responseEnum,Exception e) {
        e.printStackTrace();
        this.code = responseEnum.getCode();
        this.message = responseEnum.getMessage();
    }
}